package com.simple.vo;

import java.util.HashMap;
import java.util.Map;

/**
 * @description 系统json返回统一格式实体
 * @author lub
 * @date 2017年11月30日
 */
public class JsonResultData {
	
	private String status;
	
	private String msg;
	
	private Map<String, Object> value;
	
	private JsonResultData() {
		
	}
	
	public static JsonResultData success() {
		JsonResultData data = new JsonResultData();
		data.status = "1";
		data.msg = "success";
		data.value = new HashMap<String, Object>();
		return data;
	}
	
	public void addObject(String key, Object value) {
		this.value.put(key, value);
	}
	
	/**
	 * 此方法会把data数据清空
	 * @param message
	 * @return
	 */
	public JsonResultData turnError(String message) {
		this.status = "2";
		this.msg = message;
		this.value.clear();
		return this;
	}

	public String getStatus() {
		return status;
	}

	public String getMsg() {
		return msg;
	}

	public Map<String, Object> getValue() {
		return value;
	}
}
